package com.chhlz.module.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chhlz.module.base.dao.DishUnitDao;
import com.chhlz.module.base.model.DishUnit;
import com.chhlz.module.service.DishUnitService;

@Service
public class DishUnitServiceImpl implements DishUnitService{
	@Autowired
	private DishUnitDao dishUnitDao;

	@Override
	public int save(DishUnit t) {
		return this.dishUnitDao.save(t);
	}

	@Override
	public void update(DishUnit t) {
		this.dishUnitDao.update(t);
	}

	@Override
	public void delete(int id) {
		DishUnit du = this.dishUnitDao.get(id);
		this.dishUnitDao.delete(du);
	}

	@Override
	public List<DishUnit> findAll(int page, int rows, String sort, String order) {
		return this.dishUnitDao.findAll(page, rows, sort, order);
	}

	@Override
	public boolean isExist(String name) {
		boolean flag = false;
		String hql = "select * from DishUnit u where u.duName=" + name;
		if(this.dishUnitDao.find(hql).size()>0)
			flag = true;
		return flag;
	}

	@Override
	public int getTotal() {
		return this.dishUnitDao.countAll();
	}

}
